export default (targetElement, callBack) => {

    const handleClick = (event) => {
        if (targetElement.value && !targetElement.value.contains(event.target)) {
            callBack()
        }
    }

    onMounted(() => {
        document.addEventListener('click', handleClick);
    });

    onUnmounted(() => {
        document.removeEventListener('click', handleClick);
    });
};